﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.IO;

namespace QrlWebRole
{
  /// <summary>
  /// Summary description for RegisterIE
  /// </summary>
  public class RegisterIE : IHttpHandler
  {

    public void ProcessRequest( HttpContext context )
    {
      context.Response.ContentType = "text/xml";
      XDocument doc = XDocument.Load( Path.Combine( context.Request.PhysicalApplicationPath, "registerIE.xml" ) );

      string xml = doc.ToString().Replace( "http://qrl.cloudapp.net", HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + (HttpContext.Current.Request.ApplicationPath == "/" ? "": HttpContext.Current.Request.ApplicationPath) );
      context.Response.Write( xml );
    }

    public bool IsReusable
    {
      get
      {
        return true;
      }
    }
  }
}